package Primitives 
{
	import net.flashpunk.graphics.Image;
	import players.Player;
	import net.flashpunk.FP;
	//import Object;
	/**
	 * ...
	 * @author Alex
	 */
	public class Ramp extends Primitive 
	{
		private var _ramp:Image;
		private var _orientation:String;
		public var time:Number = 0;
		public var pX:Number = 0;
		
		public function Ramp() 
		{
			_orientation = "left"; //default orientation
			_ramp = new Image(GC.GFX_RAMP);//Image.createRect(32,32,0xFFFFFF);
			
			setHitbox(32, 32);
			graphic = _ramp;
			layer = 1;
			
			mass = 10;
			type = GC.RAMP;
		}
		
		public function setOrientation (newOrientation:String):void
		{
			if (_orientation != newOrientation)
			{				
				_ramp.flipped = true;
				_orientation = newOrientation;
			}			
		}
		
		public function getOrientation():String 
		{
			return _orientation;
		}		
		
		public function moveEntity():void
		{
			var p:Player = collide(GC.PLAYER, x, y) as Player;
			//var time:Number = 0;
			//time += FP.elapsed;
			if (p)				
			{	
				if (p.x>pX && _orientation=="left") //check if player is moving left
					{
						p.y = p.y-2;
						
					}
				else if (p.x < pX && _orientation == "right")
				{
					p.y = p.y-2;
					
				}
				pX = p.x;
			}
			
		}
		
		
		override public function update():void 
		{
			moveEntity();
		}
		
		
		
	}

}